import { BrowserRouter as Router, Route, Link, NavLink } from "react-router-dom";

const Search = () => {
  return <div>Search组件</div>
}
const Goods = () => {
  return <div>Goods组件</div>
}

const App = () => {
  // react-router-dom 使用 5.3.0 版本
  // 核心组件：Router(HashRouter，BrowserRouter) Route Link
  // Router 包裹根组件
  // Link  导航菜单
  return (
    <Router>
      <div className="app">
        <h1>根组件</h1>
      </div>
      <ul>
        <li>
          <Link to="/search">搜索</Link>
        </li>
        <li>
          <Link to="/goods">商品</Link>
        </li>
      </ul>
      {/* 路由规则 */}
      {/* <Route path="/search" component={Search}></Route> */}
      <Route path="/search">
        <Search />
      </Route>
      <Route path="/goods">
        <Goods />
      </Route>
      {/* 不写path，任何路由地址能够匹配 */}
      <Route>
        没有path的路由规则
      </Route>
    </Router>
  );
};

export default App;
